MyMsg->HD_Msg.mn_ReplyPort=MyPort; /*Where HDOff should reply to...*/
MyMsg->HD_Msg.mn_Node.ln_Type=NT_MESSAGE;
MyMsg->HD_Msg.mn_Length=sizeof(struct HD);
MyMsg->HD_Reserved=0L; /*To be sure!*/
MyMsg->HD_Cmd=Command; /*Our command*/
/*NOTE: Forbid'ing is essential! HDOff could go away right after we
got its port, and we would post a message to an invalid address!*/
Forbid();
if((HDPort=FindPort("HDOFF_PORT"))) { /*Find HDOff's port address*/
PutMsg(HDPort, (struct Message *) MyMsg);
Permit();
}
else { /*We couldn't find HDOff!*/
Permit();
printf("HDOff isn't active!\n");
FreeMem(MyMsg, sizeof(struct HD));
DeletePort(MyPort);
exit(RETURN_FAIL);
}
}
main() {
/* Try to create a messageport without name and the priority -1*/
if( !(MyPort=CreatePort(NULL, -1))) {
printf("Couldn't create messageport!\n");
exit(RETURN_FAIL);
}
/*Now we allocate the memory used for our messages*/
if (MyMsg = (struct HD *) AllocMem(sizeof(struct HD), MEMF_PUBLIC | MEMF_CLEAR))
{
/*Call GetStats*/
DoMessage(hd_GetStats);
WaitPort(MyPort); /*Wait for an answer...*/
MyMsg = (struct HD *)GetMsg(MyPort); /*Get the answer from the waiting stack*/
/*Print every information we got:*/
printf("Current status of HDOff:\nStart time HD0 : %d min\nStart time HD1 : %d min\nTime left HD0 : %d:%02d min\nTime left HD1 : %d:%02d min\nStatus HD0 : %s\nStatus HD1 : %s\nPort version : %d.%02d\n",